﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using YJTMedicalAideManage.Cores.Models;

namespace YJTMedicalAideManage.Cores.Events
{
    public class AddDressEvent
    {
        private static AddDressEvent _instance;

        private AddDressEvent() { }

        public static AddDressEvent Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new AddDressEvent();
                }
                return _instance;
            }
        }
        public delegate void AddDressEventHandler(adddress adddress);
        public delegate void AddCtiyEventHandler(adddress adddress);

        public event AddDressEventHandler OnMessageReceived;
        public event AddCtiyEventHandler OnCMessageReceived;

        public void PushMessage(adddress message)
        {
            OnMessageReceived?.Invoke(message); // 触发事件
        }
        public void Subscribe(AddDressEventHandler handler)
        {
            OnMessageReceived += handler;
        }
        public void PushMessages(adddress message)
        {
            OnCMessageReceived?.Invoke(message); // 触发事件
        }
        public void Subscribes(AddCtiyEventHandler handler)
        {
            OnCMessageReceived += handler;
        }

        public void Unsubscribe(AddDressEventHandler handler)
        {
            OnMessageReceived -= handler;
        }
    }
}
